//
//  LoadingView.swift
//  FirstSwiftProduct
//
//  Created by 知合金服-Mini on 2017/12/14.
//  Copyright © 2017年 范泽华. All rights reserved.
//

import UIKit
import Lottie


class LoadingView: UIView {

    private var lottView:LOTAnimationView!
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        lottView = LOTAnimationView.init(name: "servishero_loading")

        let realScreen = SCREEN_WIDTH < SCRENN_HEIGHT ? SCREEN_WIDTH : SCRENN_HEIGHT
        
        
        lottView.frame = CGRect(x: 0, y: 0, width: 400/375 * realScreen, height: 400/375 * realScreen)
        lottView.center = self.center
        lottView.contentMode = .scaleAspectFill

        self.addSubview(lottView)

        lottView.loopAnimation = true


        
    }
    
    public func active()  {
        lottView.play()
    }
    
    public func stopActive()  {
        lottView.stop()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    /*
    // Only override draw() if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    override func draw(_ rect: CGRect) {
        // Drawing code
    }
    */

}
